package com.hackdf.ecographic;

import com.visionapps.demo.swipe.activity.MainActivity;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Window;

public class Splash extends Activity{
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_splash);
		
		
		Handler x = new Handler();
		x.postDelayed(new SplashHandler(),2000);
	}
	
	class SplashHandler implements Runnable{		
		public void run(){		    
			SharedPreferences preferencias1 = getSharedPreferences("prefs", MODE_PRIVATE);
			SharedPreferences.Editor editor1 = preferencias1.edit();
			if(preferencias1.getString("bandera", "0").equals("0")){
				editor1.putString("bandera","1").commit();
				Intent intent = new Intent(Splash.this, Bienvenida.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			    startActivity(intent);
			    finish();
			}else{
				Intent intent = new Intent(Splash.this, MainActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			    startActivity(intent);
			    finish();
				
			}
//			Intent intent = new Intent(getApplication(), Bienvenida.class);
//		    startActivity(intent);
//		    finish();
		}
	}
}